import React from 'react'
import {
	observer,
	inject
}from 'mobx-react'
import PropTypes from 'prop-types'
import { AppState } from '../../store/app-state'

@inject('appState') @observer
export default class TopicList extends React.Component {

	constructor(){
		super()
		this.changeName = this.changeName.bind(this);
	}
	asyncBootstrap () {
		var that = this
		return new Promise( (resolve) => {
			setTimeout(function(){
				that.props.appState.count -= 3
				resolve(true)
			},2000)
		})
	}
	changeName (event){
		this.props.appState.changeName(event.target.value)
	}

	render() {
		return (
			<div> 
				<input onChange={this.changeName} />
				<span>{this.props.appState.msg}</span>
			</div>
		)
	}
} 


TopicList.propTypes = {
	appState : PropTypes.instanceOf(AppState),

}


